﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SubSonic;
using CXDB;
using Coolite.Ext.Web;
public partial class Search_Provider_View : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["id"] != null)
        {
            string id = Request["id"];
            Query q = new Query(CxApply.Schema);
            q.AddWhere("id", id);
            q.AddWhere("uid", Cookies.getCookies("cuid"));
            q.SetSelectList("bossnod,dateadd(day,15,bosstime),guid");
            if (q.GetRecordCount() == 0)
            {
                Err.Warning("没有数据！", MessageBox.Icon.ERROR);
                return;
            }
            IDataReader dr = q.ExecuteReader();
            if (dr.Read())
            {
                if (dr["bossnod"].ToString() == "0")
                {
                    Err.Warning("请等待审核！", MessageBox.Icon.ERROR);
                    return;
                }
                if (dr["bossnod"].ToString() == "2")
                {
                    Err.Warning("未通过审核！", MessageBox.Icon.ERROR);
                    return;
                }
                if (DateTime.Parse(dr[1].ToString()) <= DateTime.Now)
                {
                    Err.Warning("您的申请已过期，请重新申请！", MessageBox.Icon.WARNING);
                    return;
                }
                if (dr["bossnod"].ToString() == "1")
                {

                    //开始输出数据
                    //Err.Warning(dr["guid"].ToString(), MessageBox.Icon.WARNING);
                    Query query = new Query(VwProviderRep.Schema);
                    query.AddWhere("guid", dr["guid"].ToString());
                    IDataReader r = query.ExecuteReader();
                    if (r.Read())
                    {
                        tfProviderName.Text = r["providername"].ToString();
                        tfDeviceName.Text = r["devicename"].ToString();
                        tfSham_time.Text = r["sham_time"].ToString();
                        tfSham_project.Text = r["sham_project"].ToString();
                        tfSham_detail.Text = r["sham_detail"].ToString();
                        tfXinghu_time.Text = r["xinghu_time"].ToString();
                        tfXinghu_project.Text = r["xinghu_project"].ToString();
                        tfXinghu_detail.Text = r["xinghu_detail"].ToString();
                        tfContract_time.Text = r["contract_time"].ToString();
                        tfContract_project.Text = r["contract_project"].ToString();
                        tfContract_detail.Text = r["contract_detail"].ToString();
                        tfother_detail.Text = r["other_detail"].ToString();
                        //tfEntering_userid.Text = Username(r["entering_userid"].ToString());
                        //tfEntering_deptname.Text = r["entering_deptid"].ToString();  //部门
                        tfDept_master_ID.Text = "负责人：" + Username(r["dept_master_id"].ToString());
                        tfDept_master_time.Text = "时间：" + r["dept_master_time"].ToString();
                        //tfDept_master_status.Text = Status(r["dept_master_status"].ToString());
                        tfDept_master_remark.Text = r["dept_master_remark"].ToString();
                        tfTech_master_ID.Text = "负责人：" + Username(r["tech_master_id"].ToString());
                        tfTech_master_time.Text = "时间：" + r["tech_master_time"].ToString();
                        //tfTech_master_status.Text = Status(r["tech_master_status"].ToString());
                        tfTech_master_remark.Text = r["tech_master_remark"].ToString();
                        tfOffice_master_ID.Text = "负责人："+ Username(r["office_master_id"].ToString());
                        tfOffice_master_time.Text = "时间："+r["office_master_time"].ToString();
                        //tfOffice_master_status.Text = Status(r["office_master_status"].ToString());
                        tfOffice_master_remark.Text = r["office_master_remark"].ToString();
                        tfBoss_ID.Text = "审核人  ："+Username(r["boss_id"].ToString());
                        tfboss_time.Text = "时间："+ r["boss_time"].ToString();
                        //tfboss_status.Text = Status(r["boss_status"].ToString());
                        tfboss_remark.Text = r["boss_remark"].ToString();
                        //tfintime.Text = r["intime"].ToString();
                        //string[] str = CXFileUpload.show(new Guid(dr["guid"].ToString())).Split('$');
                        //tfzip.Text = str[1];
                        //tfzip.NavigateUrl = str[0];
                    }

                }

            }

        }
    }
    protected string Username(string uid)
    {
        if (uid == "")
        {
            return "未指定";
        }
        Query q = new Query(CxUserBase.Schema);
        q.AddWhere("uid", uid);
        q.SetSelectList("username");
        return q.ExecuteScalar().ToString();
    }
    protected string Status(string s)
    {
        switch (s)
        {
            case "0":
                return "未审核";
                break;
            case "1":
                return "同意";
                break;
            case "2":
                return "退回";
                break;
            default:
                break;
        }
        return "未知";
    }
}
